<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: LLg
  Date: 2022/10/1
  Time: 22:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>新能源汽车动力信息</title>
    <script src="js/jquery-3.6.0.js"></script>
</head>
<body>
<h1 align="center">新能源汽车动力信息</h1>
<table border="1px" align="center">
    <tr align="center">
        <td>编号</td>
        <td>车型</td>
        <td>所属城市</td>
        <td>使用单位</td>
        <td>压差报警值</td>
        <td>报警时间</td>
        <td>操作</td>
    </tr>
    <c:forEach items="${list}" var="power">
        <tr align="center">
            <td><a href="SelectList?id=${power.id}"/>${power.id}</td>
            <td>${power.carName}</td>
            <td>${power.cityName}</td>
            <td>${power.userName}</td>
            <td>${power.pressureValue}</td>
            <td>${power.time}</td>
            <td><a href="javascript:void(0)" onclick="del('${power.id}')">删除</a></td>
        </tr>
    </c:forEach>
</table>
<a href="FruitListServlet">水果信息</a>&nbsp&nbsp&nbsp&nbsp&nbsp<a href="ResumeListServlet">个人简历信息列表</a>&nbsp&nbsp&nbsp&nbsp<a href="MovieLimitServlet">电影信息</a>
<script>
    $(function (){
        $("table tr:odd").css("background-color","pink")
        $("table tr:eq(0)").css("background-color","yellow")
    })
    function del(id) {
        if (confirm("确认要删除吗？")) {
            $.getJSON(
                "DeleteList",
                {id: id},
                function (data) {
                    if (data) {
                        alert("删除成功!")
                        location.href='PowerList';
                    } else {
                        alert('删除失败!')
                    }
                }
            )
        }
    }
</script>
</body>
</html>
